from django.db import models

# 商品分类表
class Category(models.Model):
    name=models.CharField(max_length=32,unique=True)
    # 0 无效   1 有效
    status=models.IntegerField(default=0)
    addtime=models.DateTimeField(auto_now_add=True)

    class Meta:
        db_table='category'


class Goods(models.Model):
    name=models.CharField(max_length=32,unique=True)
    price=models.DecimalField(max_digits=9,decimal_places=2)
    img=models.ImageField(upload_to='img')
    status=models.IntegerField(default=0)
    addtime=models.DateTimeField(auto_now_add=True)
    cate=models.ForeignKey('Category',on_delete=models.CASCADE)

    class Meta:
        db_table='goods'
